'''

进程之间进行通信，需要用到队列
'''
from multiprocessing import Queue
from multiprocessing import Process
import os

def download(task_name,q):
    im = list("ABCDEFG")
    for i in im:
        print("任务id:{}正在执行下载任务，正在下载:{}".format(os.getpid(),i))

        q.put(i)
def savefile(task_name,q):
    while True:
        try:
            print("任务id:{}正在执行转存任务，正在转存:{}".format(os.getpid(), q.get(timeout=5)))
        except:
            break

if __name__ == '__main__':
    number = 3
    q = Queue(3)
    p = Process(target=download,args=("下载任务",q))
    p.start()
    p1 = Process(target=savefile,args=("转存任务",q))
    p1.start()

